package com.huanzhidadi.mockstatic;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 调用另一个工具类
 */
@Component
public class TestUtil implements InitializingBean {

    @Resource
    private FeignUtil feignUtilRes;

    // 静态变量前不能加Resource注解，不加的话会报空指针异常
    // 这里利用类初始化的机制给静态变量赋值
    private static FeignUtil feignUtil;

    @Override
    public void afterPropertiesSet() throws Exception {
        feignUtil = feignUtilRes;
    }

    public static String method() throws Exception {
        String result = feignUtil.connect();
        return result;
    }

}
